home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-03-05 | 10.3 KB | 478 lines | [TEXT/MPS ] |
- /*------------------------------------------------------------------------------
- #
- # Quill
- #
- # Apple Macintosh User Programming Group
- #
- # MultiFinder-Aware, AppleEvents-Aware Simple Styled TextEdit Sample Application
- #
- # by Bennet Marks
- #
- # Copyright © 1991 Apple Computer, Inc.
- #
- # Quill based on TEStyleSample (Copyright © 1989 Apple Computer, Inc.)
- #
- #
- # Quill.r - Rez Source
- #
- # All rights reserved.
- #
- # Versions: 1.0 02/18/91
- #
- # Components: Quill.p
- # QuillGlue.a
- # Quill.r
- # Quill.h
- # Quill.make
- #
- # Quill is an example application that demonstrates how
- # to initialize the commonly used toolbox managers, operate
- # successfully under MultiFinder, handle desk accessories and
- # create, grow, and zoom windows. Both styled and fundamental TextEdit
- # toolbox calls and TextEdit autoscroll are demonstrated. It
- # also shows how to create and maintain scrollbar controls as well
- # as implementing a basic printing loop.
- #
- # It also handles AppleEvents, and is written with an eye towards
- # making it work with the AppleEvents Object Model and the Open Scripting
- # Architecture. It was built on TEStyleSample, with more functionality and
- # AppleEvent awareness added in.
- #
- # It does not by any means demonstrate all the techniques you
- # need for a large application. In particular, Quill does not
- # cover exception handling, multiple windows/documents,
- # sophisticated memory management, or undo. All of
- # these are vital parts of a normal full-sized application.
- #
- # This application is an example of the form of a Macintosh
- # application; it is NOT a template. It is NOT intended to be
- # used as a foundation for the next world-class, best-selling,
- # 600K application. A stick figure drawing of the human body may
- # be a good example of the form for a painting, but that does not
- # mean it should be used as the basis for the next Mona Lisa.
- #
- # We recommend that you review this program, TESample or Sample before
- # beginning a new application. TESample is a simpler version of Quill
- # without styles and Sample is a simple app. which doesn’t
- # use TextEdit or the Control Manager.
- #
- ------------------------------------------------------------------------------*/
-
- /*------------------------------------------------------------------------------
- # Modification History
- #
- # 02/18/91 BHM New today
- # 02/21/91 BHM Put in rUserError (used in addition to rUserAlert)
- # 02/25/91 BHM Added "Print File" item to edit menu
- # 03/01/91 BHM Put in rYesOrNo ALRT and DITL
- # 03/06/91 BHM Added a new error string (not one we would ever want
- # a user to see)
- # 05/31/91 BHM Added "Quit NOW" file menu command
-
- ------------------------------------------------------------------------------*/
-
- #include "SysTypes.r"
- #include "Types.r"
- #include "Quill.h"
-
-
-
- resource 'vers' (1) {
- 0x01, 0x00, development, 0x01, verUS,
- "1.0d1",
- "1.0d1, Copyright © Apple Computer, Inc. 1991-1992 "
- };
-
- /* we use an MBAR resource to conveniently load all the menus */
-
- resource 'MBAR' (rMenuBar, preload) {
- { mApple, mFile, mEdit, mFont, mFontSize, mStyle, mMathoms }; /* seven menus */
- };
-
-
- resource 'MENU' (mApple, preload) {
- mApple, textMenuProc,
- AllItems & ~MenuItem2, /* disable dashed line, enable About and DAs */
- enabled, apple,
- {
- "About Quill…",
- noicon, nokey, nomark, plain;
- "-",
- noicon, nokey, nomark, plain
- }
- };
-
- resource 'MENU' (mFile, preload) {
- mFile, textMenuProc,
- NoItems, /* disable everything, program does the enabling */
- enabled, "File",
- {
- "New",
- noicon, "N", nomark, plain;
- "Open",
- noicon, "O", nomark, plain;
- "-",
- noicon, nokey, nomark, plain;
- "Close",
- noicon, "W", nomark, plain;
- "Save",
- noicon, "S", nomark, plain;
- "Save As…",
- noicon, nokey, nomark, plain;
- "Revert",
- noicon, nokey, nomark, plain;
- "-",
- noicon, nokey, nomark, plain;
- "Page Setup…",
- noicon, nokey, nomark, plain;
- "Print…",
- noicon, nokey, nomark, plain;
- "Print File…",
- noicon, nokey, nomark, plain;
- "-",
- noicon, nokey, nomark, plain;
- "Quit",
- noicon, "Q", nomark, plain;
- "Quit NOW",
- noicon, nokey, nomark, plain
- }
- };
-
- resource 'MENU' (mEdit, preload) {
- mEdit, textMenuProc,
- NoItems, /* disable everything, program does the enabling */
- enabled, "Edit",
- {
- "Undo",
- noicon, "Z", nomark, plain;
- "-",
- noicon, nokey, nomark, plain;
- "Cut",
- noicon, "X", nomark, plain;
- "Copy",
- noicon, "C", nomark, plain;
- "Paste",
- noicon, "V", nomark, plain;
- "Clear",
- noicon, nokey, nomark, plain;
- "-",
- noicon, nokey, nomark, plain;
- "Select All",
- noicon, "A", nomark, plain
- }
- };
-
- /* Added for TEStyleSample */
- /* Font Menu */
- resource 'MENU' (mFont, preload) {
- mFont, textMenuProc,
- AllItems, /* enable everything since these are fonts */
- enabled, "Font",
- {
- }
- };
-
- /* Added for TEStyleSample */
- /* Size Menu Items */
- resource 'MENU' (mFontSize, preload) {
- mFontSize, textMenuProc,
- AllItems, /* enable everything, since these are font sizes */
- enabled, "Font Size",
- {
- "9 Point", noIcon, noKey, noMark, plain,
- "10 Point", noIcon, noKey, noMark, plain,
- "12 Point", noIcon, noKey, noMark, plain,
- "14 Point", noIcon, noKey, noMark, plain,
- "18 Point", noIcon, noKey, noMark, plain,
- "24 Point", noIcon, noKey, noMark, plain
- }
- };
-
- /* Added for TEStyleSample */
- /* Style Menu Items */
- resource 'MENU' (mStyle, preload) {
- mStyle, textMenuProc,
- AllItems & ~MenuItem2, /* enable everything except dash */
- enabled, "Style",
- {
- "Plain",
- noicon, "P", nomark, plain;
- "-",
- noicon, nokey, nomark, plain;
- "Bold",
- noicon, "B", nomark, bold;
- "Italic",
- noicon, "I", nomark, italic;
- "Underline",
- noicon, "U", nomark, underline;
- "Outline",
- noicon, nokey, nomark, outline;
- "Shadow",
- noicon, nokey, nomark, shadow
- }
- };
-
- resource 'MENU' (mMathoms, preload) {
- mMathoms, textMenuProc,
- NoItems, /* disable everything, program does the enabling */
- enabled, "Mathoms",
- {
- "Show All Errors",
- noicon, nokey, nomark, plain
- }
- };
-
-
- /* this ALRT and DITL are used as an About screen */
-
- resource 'ALRT' (rAboutAlert, purgeable) {
- {40, 20, 160, 350}, rAboutAlert, {
- OK, visible, silent;
- OK, visible, silent;
- OK, visible, silent;
- OK, visible, silent
- };
- };
-
- resource 'DITL' (rAboutAlert, purgeable) {
- { /* array DITLarray: 5 elements */
- /* [1] */
- {88, 234, 108, 314},
- Button {
- enabled,
- "OK"
- },
- /* [2] */
- {8, 8, 24, 350},
- StaticText {
- disabled,
- "AppleEvents-Aware Styled TextEdit Application"
- },
- /* [3] */
- {32, 8, 48, 350},
- StaticText {
- disabled,
- "Copyright © Apple Computer 1991-1992"
- },
- /* [4] */
- {56, 8, 72, 136},
- StaticText {
- disabled,
- "Brought to you by:"
- },
- /* [5] */
- {80, 24, 112, 167},
- StaticText {
- disabled,
- "Bennet Marks - DTE"
- }
- }
- };
-
-
- /* this ALRT and DITL are used as an error screen */
-
- resource 'ALRT' (rUserError, purgeable) {
- {40, 20, 150, 260},
- rUserError,
- { /* array: 4 elements */
- /* [1] */
- OK, visible, silent,
- /* [2] */
- OK, visible, silent,
- /* [3] */
- OK, visible, silent,
- /* [4] */
- OK, visible, silent
- }
- };
-
-
- resource 'DITL' (rUserError, purgeable) {
- { /* array DITLarray: 3 elements */
- /* [1] */
- {80, 150, 100, 230},
- Button {
- enabled,
- "OK"
- },
- /* [2] */
- {10, 60, 60, 230},
- StaticText {
- disabled,
- "Error. ^0."
- },
- /* [3] */
- {8, 8, 40, 40},
- Icon {
- disabled,
- 2
- }
- }
- };
-
- /* this ALRT and DITL are used as an alert screen */
-
- resource 'ALRT' (rUserAlert, purgeable) {
- {40, 20, 250, 360},
- rUserAlert,
- { /* array: 4 elements */
- /* [1] */
- OK, visible, silent,
- /* [2] */
- OK, visible, silent,
- /* [3] */
- OK, visible, silent,
- /* [4] */
- OK, visible, silent
- }
- };
-
-
- resource 'DITL' (rUserAlert, purgeable) {
- { /* array DITLarray: 3 elements */
- /* [1] */
- {180, 250, 200, 330},
- Button {
- enabled,
- "OK"
- },
- /* [2] */
- {10, 60, 160, 330},
- StaticText {
- disabled,
- "Listen up: ^0."
- },
- /* [3] */
- {8, 8, 40, 40},
- Icon {
- disabled,
- 2
- }
- }
- };
-
-
-
- /* this ALRT and DITL are used for a yes/no/cancel screen */
-
- resource 'ALRT' (rYesOrNo, purgeable) {
- {100,120, 220, 358},
- rYesOrNo,
- { /* array: 4 elements */
- /* [1] */
- OK, visible, silent,
- /* [2] */
- OK, visible, silent,
- /* [3] */
- OK, visible, silent,
- /* [4] */
- OK, visible, silent
- }
- };
-
-
- resource 'DITL' (rYesOrNo, purgeable) {
- { /* array DITLarray: 4 elements */
-
- /* [1] */
- {58,25,76,99},
- Button {
- enabled,
- "YES!"
- },
-
- /* [2] */
- {86,25,104,99},
- Button {
- enabled,
- "no"
- },
-
- /* [3] */
- {86,141,104,215},
- Button {
- enabled,
- "cancel"
- },
-
-
- /* [4] */
- {12,20,45,223},
- StaticText {
- disabled,
- "^0"
- }
- }
- };
-
-
-
- resource 'WIND' (rDocWindow, preload, purgeable) {
- {64, 60, 314, 460},
- zoomDocProc, invisible, goAway, 0x0, "untitled"
- };
-
-
- resource 'CNTL' (rVScroll, preload, purgeable) {
- {-1, 385, 236, 401},
- 0, visible, 0, 0, scrollBarProc, 0, ""
- };
-
-
- resource 'CNTL' (rHScroll, preload, purgeable) {
- {235, -1, 251, 386},
- 0, visible, 0, 0, scrollBarProc, 0, ""
- };
-
- resource 'STR#' (kErrStrings, purgeable) {
- {
- "You must run on 512Ke or later";
- "Application Memory Size is too small";
- "Not enough memory to run Quill";
- "Not enough memory to do Cut";
- "Cannot do Cut";
- "Cannot do Copy";
- "Cannot exceed 32,000 characters with Paste";
- "Not enough memory to do Paste";
- "Cannot create window";
- "Cannot exceed 32,000 characters";
- "Cannot do Paste";
- "Could not create self-address descriptor"
- }
- };
-
- /* here is the quintessential MultiFinder friendliness device, the SIZE resource */
-
- resource 'SIZE' (-1) {
- dontSaveScreen,
- acceptSuspendResumeEvents,
- enableOptionSwitch,
- canBackground, /* we can background; we don't currently, but our sleep value */
- /* guarantees we don't hog the Mac while we are in the background */
- doesActivateOnFGSwitch, /* this says we do our own activate/deactivate; don't fake us out */
- backgroundAndForeground, /* this is definitely not a background-only application! */
- dontGetFrontClicks, /* change this is if you want "do first click" behavior like the Finder */
- ignoreAppDiedEvents, /* essentially, I'm not a debugger (sub-launching) */
- not32BitCompatible, /* this app should not be run in 32-bit address space */
- isHighLevelEventAware, /* <aevt */
- localAndRemoteHLEvents, /* <aevt */
- reserved,
- reserved,
- reserved,
- reserved,
- reserved,
- kPrefSize * 1024,
- kMinSize * 1024
- };
-
-
- type 'quil' as 'STR ';
-
-
- resource 'quil' (0) {
- "AppleEvents-Aware Styled TextEdit Sample Application"
- };
-
-
- include "Quill.rsrc" not 'ckid';